<?php

if(! defined('OT_ROOT')) {
	exit('Access Denied');
}


class AppIdcPro{
	public static $appName = 'IDC产品管理';
	private static $isApp = 0;



	public static function InfoTypeOptionBox1($IT_mode){
		return '
			<option value="idcPro" '. Is::Selected($IT_mode,'idcPro') .'>IDC产品页</option>
			';
	}


	public static function InfoTypeTrBox1($IT_webID){
		global $DB;

		$retStr = '
			<tr>
				<td align="right">'. Skin::PluSign(self::$appName) .'IDC产品类别：</td>
				<td>
					<select id="idcProID" name="idcProID">
						<option value="">请选择</option>
						';
						$typeNum = 0;
						$typeexe=$DB->query('select IPT_ID,IPT_theme from '. OT_dbPref ."idcProType where IPT_state=1 and IPT_level=1 order by IPT_rank ASC");
						if (! $row = $typeexe->fetch()){
							$retStr .= '<option value="" style="color:#9d9d9d;">无记录，请到【辅助管理】-【IDC产品类别】里添加</option>';
						}else{
							do{
								$typeNum ++;
								$type2exe=$DB->query('select IPT_ID,IPT_theme,IPT_htmlName from '. OT_dbPref ."idcProType where IPT_state=1 and IPT_level=2 and IPT_fatID=". $row['IPT_ID'] ." order by IPT_rank ASC");
								// if (! $row2 = $type2exe->fetch()){
									$retStr .= '<option value="'. $row['IPT_ID'] .'" '. Is::InstrSelected($IT_webID, $row['IPT_ID']) .'>'. $typeNum .'、'. $row['IPT_theme'] .'</option>';
								// }else{
								//	$retStr .= '<optgroup label="'. $typeNum .'、'. $row['IPT_theme'] .'" style="font-weight:normal;"></optgroup>';
									while ($row2 = $type2exe->fetch()){
										$retStr .= '
											<option value="'. $row2['IPT_ID'] .'" '. Is::InstrSelected($IT_webID, $row2['IPT_ID']) .'>&ensp;&ensp;&ensp;┣&ensp;'. $row2['IPT_theme'] .'</option>
											<option value="-'. $row2['IPT_ID'] .'" '. Is::InstrSelected($IT_webID, $row2['IPT_ID']*(-1)) .'>&ensp;&ensp;&ensp;┣&ensp;'. $row2['IPT_theme'] .'（静态页）'. $row2['IPT_htmlName'] .'</option>
											';
									}
								// }
							}while ($row = $typeexe->fetch());
						}

					$retStr .= '
					</select>
				</td>
			</tr>
			';
			return $retStr;
	}



	// 列表页 菜单
	public static function ListMenuBox($typeID,$selID,$isHtml = 0){
		global $DB;

		$retStr = '';
		$menuexe = $DB->query('select IPT_ID,IPT_theme,IPT_htmlName from '. OT_dbPref .'idcProType where IPT_state=1 and IPT_fatID='. $typeID .' order by IPT_rank ASC');
		while ($mrs = $menuexe->fetch()){
			$retStr .= '<a href="'. ($isHtml == 0 ? '?dataID='. $mrs['IPT_ID'] : $mrs['IPT_htmlName']) .'" '. ($mrs['IPT_ID'] == $selID ? 'class="active"' : '') .'>'. $mrs['IPT_theme'] .'</a>';
		}
		unset($menuexe);

		return $retStr;
	}


	// WAP列表页 菜单
	public static function WapListMenuBox($typeID,$selID,$isHtml = 0){
		global $DB;

		$retStr = '
			<div>
			<nav class="userMenu bodyActive">
			<ul>
			';

			$menuexe = $DB->query('select IPT_ID,IPT_theme,IPT_htmlName from '. OT_dbPref .'idcProType where IPT_wapState=1 and IPT_fatID='. $typeID .' order by IPT_rank ASC');
			while ($mrs = $menuexe->fetch()){
				$retStr .= '<li style="min-width:33.33%;"><a href="'. ($isHtml == 0 ? '?dataID='. $mrs['IPT_ID'] : $mrs['IPT_htmlName']) .'" '. ($mrs['IPT_ID'] == $selID ? 'class="active"' : '') .'>'. $mrs['IPT_theme'] .'</a></li>';
			}
			unset($menuexe);

		$retStr .= '
			</ul>
			</nav>
			</div>
			';

		return $retStr;
	}



	// PC列表页 - 虚拟主机
	public static function ListHost1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$retStr .= '
				<div class="hostType">
					<div class="hostTypeTitle">
						<h2 style="'. $grs['IPG_themeStyle'] .'">'. $grs['IPG_theme'] .'</h2>
						<div class="hostTypeLink"></div>
					</div>
				</div>

				<div class="hostList">
				<div class="hostListWidth">
				<ul>
				';
			$dataNum = 0;
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<center>暂无产品</center>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<p style="color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<span style="color:#ff6600; font-size:32px; font-weight:bold">'. floatval($priceRow['VAD_priceYear']) .'</span> 元/年';
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<span style="color:#ff6600; font-size:32px; font-weight:bold">'. floatval($priceRow['HD_priceYear']) .'</span> 元/年';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						$priceStr = '<span style="color:#ff6600; font-size:32px; font-weight:bold">'. floatval($rs['IPD_priceYear']) .'</span> 元/年';
					}
					if (strlen($btnUrl) > 7){ $btnStr = '<a href="'. $btnUrl .'">立即购买</a>'; }

					$retStr .= '
						<li>
							<div class="hostListTitle" style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</div>
							<div class="hostListImg"><img src="'. $tpl->webPathPart . $tpl->tplDir .'images/host01.png"></div>
							<div class="hostListCont">'. $listStr .'</div>
							<div class="hostListPrice">'. $priceStr .'</div>
							<div class="hostListBtn">'. $btnStr .'</div>
						</li>
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</ul>
			</div>
			</div>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div class="hostNote2">
				<h5>友情提醒：</h5>
				<div style="padding:12px;line-height:2;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}


	// PC列表页 - 云服务器
	public static function ListVps1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$retStr .= '
				<div class="hostType" style="width:1050px;">
					<div class="hostTypeTitle">
						<h2 style="'. $grs['IPG_themeStyle'] .'">'. $grs['IPG_theme'] .'</h2>
						<div class="hostTypeLink"></div>
					</div>
				</div>

				<div class="vpsListArea">
				<ul class="vpsList">
				';
			$dataNum = 0;
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<center>暂无产品</center>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '
								<dt class="'. self::ListVpsIco($itemArr[1]) .'">
									<span class="i"></span>
									<span class="n" style="color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $itemArr[1] .'：</span>
									'. self::ListVpsRateImg($rs['IPD_field'. $i]) .'
									<span class="v" style="color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $rs['IPD_field'. $i] .'</span>
								</dt>
								';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = ''. floatval($priceRow['VAD_priceMonth']) .'<em>/月</em> '. floatval($priceRow['VAD_price6Month']) .'<em>/半年</em> '. floatval($priceRow['VAD_priceYear']) .'<em>元/年</em>';
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = ''. floatval($priceRow['HD_priceYear']) .' <em>元/年</em>';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						$priceStr = ''. floatval($rs['IPD_priceMonth']) .'<em>/月</em> '. floatval($rs['IPD_price6Month']) .'<em>/半年</em> '. floatval($rs['IPD_priceYear']) .'<em>元/年</em>';
					}
					if (strlen($btnUrl) > 7){
						// 自助购买 vpsBtn1.jpg   淘宝购买 vpsBtn2.jpg
						$btnStr = '<a href="'. $btnUrl .'"><img src="'. $tpl->webPathPart . $tpl->tplDir .'images/vpsBtn1.jpg" width="121" height="38" /></a>';
					}

					$retStr .= '
						<li>
							<div class="vpsItem">
								<div class="itemTop"><p><span style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</span></p></div>
								<dl>'. $listStr .'</dl>
								<div class="money">'. $priceStr .'</div>
								<div class="btnBox">'. $btnStr .'</div>
							</div>
							<div class="itemBottom"></div>
						</li>
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</ul>
			</div>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div class="hostNote2">
				<h5>友情提醒：</h5>
				<div style="padding:12px;line-height:2;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}


	// PC列表页 - 服务器租用
	public static function ListServ1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupNum = 0;
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$groupNum ++;
			$groupStylePoint = $groupNum % 3 + 1;

			$retStr .= '
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="servTab1" style="margin-bottom:30px;">
				<tr>
					<td colspan="20" class="title bgf'. $groupStylePoint .'" style="'. $grs['IPG_style'] . $grs['IPG_themeStyle'] .'">'. $grs['IPG_theme'] .'</td>
				</tr>
				';
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');

			$retStr .= '
			<tr class="th bgf'. $groupStylePoint .'" style="'. $grs['IPG_style'] .'">
				<td style="width:;">产品名称</td>
				';
				for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
					$itemArr = explode('|', $fieldArr[$i-1] .'||||||');
					if ($itemArr[0] == 1 && $itemArr[3] == 1){
						$retStr .= '<td style="width:'. $itemArr[5] . (strlen($itemArr[5])<=2 ? '%' : '') .';">'. $itemArr[1] .'</td>';	//  align="'. $itemArr[6] .'"text-align:'. $itemArr[6] .';
					}
				}
			$retStr .= '
				<td>价格</td>		
			</tr>
			<tbody class="tabBody">
			';

			$dataNum = 0;
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<tr><td colspan="20" style="padding:10px;">暂无产品</td></tr>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'||||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<td align="'. $itemArr[6] .'" style="color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'text-align:'. $itemArr[6] .';width:'. $itemArr[5] . (strlen($itemArr[5])<=2 ? '%' : '') .';">'. $rs['IPD_field'. $i] .'</td>';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								if ($priceRow['VAD_priceMonth'] > 0){ $priceStr .= floatval($priceRow['VAD_priceMonth']) .'/月&ensp;'; }
								if ($priceRow['VAD_price3Month'] > 0){ $priceStr .= floatval($priceRow['VAD_price3Month']) .'/季&ensp;'; }
								if ($priceRow['VAD_price6Month'] > 0){ $priceStr .= floatval($priceRow['VAD_price6Month']) .'/半年&ensp;'; }
								if ($priceRow['VAD_priceYear'] > 0){ $priceStr .= floatval($priceRow['VAD_priceYear']) .'/年&ensp;'; }
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = ''. floatval($priceRow['HD_priceYear']) .' 元/年';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						if ($rs['IPD_priceMonth'] > 0){ $priceStr .= floatval($rs['IPD_priceMonth']) .'/月&ensp;'; }
						if ($rs['IPD_price3Month'] > 0){ $priceStr .= floatval($rs['IPD_price3Month']) .'/季&ensp;'; }
						if ($rs['IPD_price6Month'] > 0){ $priceStr .= floatval($rs['IPD_price6Month']) .'/半年&ensp;'; }
						if ($rs['IPD_priceYear'] > 0){ $priceStr .= floatval($rs['IPD_priceYear']) .'/年&ensp;'; }
					}
					if (strlen($btnUrl) > 7){
						// 自助购买 vpsBtn1.jpg   淘宝购买 vpsBtn2.jpg
						$btnStr = '<a href="'. $btnUrl .'"><img src="'. $tpl->webPathPart . $tpl->tplDir .'images/vpsBtn1.jpg" width="121" height="38" /></a>';
					}

					$retStr .= '
						<tr class="bg'. ($dataNum % 2 == 0 ? 2 : 1) .'">
							<td style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</td>
							'. $listStr .'
							<td>'. $priceStr .'</td>
						</tr>	
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</tbody>
			';
			if (strlen($grs['IPG_tixing']) > 0){
				$retStr .= '
				<tr class="bg3">
					<td colspan="10" class="paddLeft">'. $grs['IPG_tixing'] .'</td>
				</tr>	
				';
			}
			$retStr .= '
			</table>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div class="hostNote2">
				<h5>友情提醒：</h5>
				<div style="padding:12px;line-height:2;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}



	// WAP列表页 - 虚拟主机
	public static function WapListHost1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$retStr .= '
				<div class="hostTitle active" id="host'. $grs['IPG_ID'] .'" onclick="OpenHiddenBox(this.id)"><p><span>'. $grs['IPG_theme'] .'</span></p></div><!--  -->
				<ul class="hostItem" id="host'. $grs['IPG_ID'] .'Box">
				';
			$dataNum = 0;
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<center>暂无产品</center>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goWapUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<p style="color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['VAD_priceYear']) .'</span> 元/年</div>';
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['HD_priceYear']) .'</span> 元/年</div>';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						$priceStr = '<div class="priceBox price2"><span>'. floatval($rs['IPD_priceYear']) .'</span> 元/年</div>';
					}
					if (strlen($btnUrl) > 7){ $btnStr = '<div class="btnBox"><input type="button" class="btn" value="立即购买" onclick="document.location.href=\''. $btnUrl .'\';" /></div>'; }

					$retStr .= '
						<li>
							<div class="markBox"><!-- <i class="imgHot"></i> --><!-- 热销 --></div>
							<a class="itemA">
								<div class="itemLeft">
									<div class="title" style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</div>
									<div class="note">'. $listStr .'</div>
								</div>
								<div class="itemRight">
									'. $btnStr .'
									'. $priceStr .'
								</div>
							</a>
						</li>
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</ul>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div style="padding:15px;">
				<h3>友情提醒：</h3>
				<div style="padding:8px 0;line-height:1.5;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}


	// WAP列表页 - 云服务器
	public static function WapListVps1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$retStr .= '
				<div class="hostTitle active" id="host'. $grs['IPG_ID'] .'" onclick="OpenHiddenBox(this.id)"><p><span>'. $grs['IPG_theme'] .'</span></p></div><!--  -->
				<ul class="hostItem" id="host'. $grs['IPG_ID'] .'Box">
				';
			$dataNum = 0;
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<center>暂无产品</center>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goWapUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<p style="width:99%;padding-bottom:3px;color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['VAD_priceMonth']) .'</span> 元/月 <span>'. floatval($priceRow['VAD_price6Month']) .'</span> 元/半年 <span>'. floatval($priceRow['VAD_priceYear']) .'</span> 元/年</div>';
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['HD_priceYear']) .'</span> 元/年</div>';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						$priceStr = '<div class="priceBox price2"><span>'. floatval($rs['IPD_priceMonth']) .'</span> 元/月 <span>'. floatval($rs['IPD_price6Month']) .'</span> 元/半年 <span>'. floatval($rs['IPD_priceYear']) .'</span> 元/年</div>';
					}
					if (strlen($btnUrl) > 7){ $btnStr = '<div class="btnBox"><input type="button" class="btn" value="立即购买" onclick="document.location.href=\''. $btnUrl .'\';" /></div>'; }

					$retStr .= '
						<li>
							<div class="markBox"><!-- <i class="imgHot"></i> --><!-- 热销 --></div>
							<a class="itemA">
								<div class="itemLeft">
									<div class="title" style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</div>
									<div class="note">'. $listStr .'</div>
								</div>
								<div class="itemRight">
									'. $btnStr .'
									<div style="float:left;padding:3px 0 0 12px;">'. $priceStr .'</div>
								</div>
							</a>
						</li>
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</ul>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div style="padding:15px;">
				<h3>友情提醒：</h3>
				<div style="padding:8px 0;line-height:1.5;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}


	// WAP列表页 - 服务器租用
	public static function WapListServ1Box($row,$fatRow){
		global $DB,$tpl;

		$retStr = '';
		$groupexe = $DB->query('select * from '. OT_dbPref .'idcProGroup where IPG_state=1 and IPG_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPG_rank ASC');
		while ($grs = $groupexe->fetch()){
			$retStr .= '
				<div class="hostTitle active" id="host'. $grs['IPG_ID'] .'" onclick="OpenHiddenBox(this.id)"><p><span>'. $grs['IPG_theme'] .'</span></p></div><!--  -->
				<ul class="hostItem" id="host'. $grs['IPG_ID'] .'Box">
				';
			$dataNum = 0;
			$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_groupID='. $grs['IPG_ID'] .' and IPD_state=1 order by IPD_rank ASC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<center>暂无产品</center>';
			}else{
				do{
					$dataNum ++;
					$listStr = $priceStr = $btnStr = '';
					$btnUrl = $rs['IPD_goWapUrl'];

					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<p style="width:99%;padding-bottom:3px;color:'. $itemArr[2] .';'. $rs['IPD_field'. $i .'Style'] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
						}
					}

					if ($rs['IPD_priceMode'] == 1){	// 自编辑
						$priceStr = $rs['IPD_priceDiy'];
					}elseif ($rs['IPD_priceMode'] == 2){	// 调用产品
						if ($rs['IPD_proType'] == 'vps'){
							$priceRow = $DB->GetRow('select VAD_priceMonth,VAD_price3Month,VAD_price6Month,VAD_priceYear from '. OT_dbPref .'vpsApiData where VAD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['VAD_priceMonth']) .'</span> 元/月 <span>'. floatval($priceRow['VAD_price6Month']) .'</span> 元/半年 <span>'. floatval($priceRow['VAD_priceYear']) .'</span> 元/年</div>';
							}
						}elseif ($rs['IPD_proType'] == 'host' && AppHost::Jud()){
							$priceRow = $DB->GetRow('select HD_priceYear from '. OT_dbPref .'hostData where HD_ID='. $rs['IPD_proID']);
							if ($priceRow){
								$priceStr = '<div class="priceBox price2"><span>'. floatval($priceRow['HD_priceYear']) .'</span> 元/年</div>';
							}
						}
						$btnUrl = $tpl->webPathPart .'usersCenter.php?mudi='. $rs['IPD_proType'] .'KaitongDet&dataID='. $rs['IPD_proID'];
					}
					if (strlen($priceStr) == 0){
						$priceStr = '<div class="priceBox price2"><span>'. floatval($rs['IPD_priceMonth']) .'</span> 元/月 <span>'. floatval($rs['IPD_price6Month']) .'</span> 元/半年 <span>'. floatval($rs['IPD_priceYear']) .'</span> 元/年</div>';
					}
					if (strlen($btnUrl) > 7){ $btnStr = '<div class="btnBox"><input type="button" class="btn" value="立即购买" onclick="document.location.href=\''. $btnUrl .'\';" /></div>'; }

					$retStr .= '
						<li>
							<div class="markBox"><!-- <i class="imgHot"></i> --><!-- 热销 --></div>
							<a class="itemA">
								<div class="itemLeft">
									<div class="title" style="'. $rs['IPD_themeStyle'] .'">'. $rs['IPD_theme'] .'</div>
									<div class="note">'. $listStr .'</div>
								</div>
								<div class="itemRight">
									'. $btnStr .'
									<div style="float:left;padding:3px 0 0 0;">'. $priceStr .'</div>
								</div>
							</a>
						</li>
						';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
			</ul>
			';
		}
		unset($groupexe);

		if (strlen($row['IPT_tixing']) > 6 || strlen($fatRow['IPT_tixing']) > 6){
			$retStr .= '
			<div style="padding:15px;">
				<h3>友情提醒：</h3>
				<div style="padding:8px 0;line-height:1.5;">'. (strlen($row['IPT_tixing']) > 6 ? $row['IPT_tixing'] : $fatRow['IPT_tixing']) .'</div>
			</div>
			';
		}

		return $retStr;
	}



	// 云服务器图标
	public static function ListVpsIco($str){
		$retStr = 'line';
		switch ($str){
			case 'CPU':		$retStr = 'cpu';	break;
			case '内存':	$retStr = 'ram';	break;
			case '数据盘': 
			case '硬盘':	$retStr = 'disk';	break;
			case '带宽':	$retStr = 'bandwidth';	break;
			case '独立IP': 
			case 'IP':		$retStr = 'ip';		break;
			case '系统':	$retStr = 'system';	break;
			case '机房':	$retStr = 'jf';		break;
			case '优惠':	$retStr = 'line';	break;
		}
		return $retStr;
	}

	// 云服务器进度图
	public static function ListVpsRateImg($str){
		global $tpl;

		$val = OT::ToInt(str_replace(array('核','G','M','B'),'',$str));
		$retStr = '';
		if ($val == 1 || $val == 2 || $val == 512 || $val == 10 || ($val == 20 || $val == 30)){
			$retStr = '1';
		}elseif ($val == 3 || $val == 4 || ($val == 30 || $val == 40 || $val == 50)){
			$retStr = '2';
		}elseif ($val == 5 || $val == 6 || ($val > 50 && $val <= 70)){
			$retStr = '3';
		}elseif ($val == 7 || $val == 8 || ($val > 70 && $val <= 100)){
			$retStr = '4';
		}elseif ($val == 9 || $val == 10 || ($val > 100 && $val <= 120)){
			$retStr = '5';
		}elseif ($val == 11 || $val == 12 || ($val > 120 && $val <= 140)){
			$retStr = '6';
		}elseif (($val >= 13 && $val <= 29) || ($val == 32 || $val == 36) || ($val > 140 && $val <= 1024)){
			$retStr = '7';
		}
		if (strlen($retStr) > 0){
			$retStr = '<span class="p"><img src="'. $tpl->webPathPart . $tpl->tplDir .'images/vpsRate'. $retStr .'.jpg" width="130" height="35" /></span>';
		}
		return $retStr;
	}

	public static function TplHome(){

	}

	// WAP前台模板底部代码
	public static function WapTplHome(){
		global $DB,$tpl;

		$retStr = '';
		$typeexe = $DB->query('select IPT_ID,IPT_theme,IPT_homeNum,IPT_fieldNum,IPT_fieldStr,IPT_priceType,IPT_homeColor from '. OT_dbPref .'idcProType where IPT_isHomeWap=1 and IPT_wapState=1 order by IPT_rank ASC');
		while ($row = $typeexe->fetch()){
			$retStr .= '
			<div class="hostTitle active"><p><span>'. $row['IPT_theme'] .'</span></p></div>
			<ul class="hostItem" id="hostHKBox">
			';

			$dataNum = 0;
			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_wapState=1 and IPD_typeStr like "%,'. $row['IPT_ID'] .',%" order by IPD_time DESC limit '. $row['IPT_homeNum']);
			while ($rs = $dataexe->fetch()){
				$dataNum ++;

				$listStr = '';
				$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
				for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
					$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
					if ($itemArr[0] == 1 && $itemArr[3] == 1){
						$listStr .= '<p style="color:'. $itemArr[2] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
					}
				}

				if ($row['IPT_priceType'] == 'vps1'){
					$priceStr = '<div class="priceBox price2"><span>'. floatval($rs['IPD_priceMonth']) .'</span>元/月 <span>'. floatval($rs['IPD_priceYear']) .'</span>元/年</div>';
				}else{
					$priceStr = '<div class="priceBox">¥'. floatval($rs['IPD_priceYear']) .'/年</div>';
				}
				if (strlen($rs['IPD_goUrl']) > 7){
					$btnStr = '<div class="btnBox"><input type="button" class="btn" value="立即购买" onclick="document.location.href=\''. $rs['IPD_goUrl'] .'\';" /></div>';
				}else{
					$btnStr = '';
				}
				$retStr .= '
				<li>
					<div class="markBox"><i class="imgHot"></i><!-- 热销 --></div>
					<a class="itemA">
						<div class="itemLeft">
							<div class="title">'. $rs['IPD_theme'] .'</div>
							<div class="note">'. $listStr .'</div>
						</div>
						<div class="itemRight">
							'. $btnStr .'
							'. $priceStr .'
						</div>
					</a>
				</li>
				';
			}
			$dataexe = null;

			$retStr .= '
			</ul>
			';
		}
		unset($typeexe);

		return $retStr;
	}



	// WAP列表页
	public static function WapListBox($dataID, $row){
		global $DB;

		$retStr = '';
		$typeArr = array();
		if ($row['IPT_level'] == 1){
			$typeexe = $DB->query('select IPT_ID,IPT_theme from '. OT_dbPref .'idcProType where IPT_fatID='. $row['IPT_ID'] .' order by IPT_rank ASC');
			while ($rs = $typeexe->fetch()){
				$typeArr[$rs['IPT_ID']] = $rs['IPT_theme'];
			}
			/* if ($rs = $typeexe->fetch()){
				$retStr .= '
					<div>
					<nav class="userMenu bodyActive">
					<ul>
						<li><a href="?dataID='. $row['IPT_ID'] .'" class="active">全部</a></li>
						';
						do{
							$retStr .= '<li><a href="?dataID='. $rs['IPT_ID'] .'">'. $rs['IPT_theme'] .'</a></li>';
						}while ($rs = $typeexe->fetch());

					$retStr .= '
					</ul>
					</nav>
					</div>
					';
			} */
			$typeexe = null;
		}elseif ($row['IPT_level'] == 2){
			$typeArr[$row['IPT_ID']] = $row['IPT_theme'];
			/* $typeexe = $DB->query('select IPT_ID,IPT_theme from '. OT_dbPref .'idcProType where IPT_fatID='. $row['IPT_fatID'] .' order by IPT_rank ASC');
			if ($rs = $typeexe->fetch()){
				$typeArr[$rs['IPT_ID']] = $rs['IPT_theme'];
				$retStr .= '
					<div>
					<nav class="userMenu bodyActive">
					<ul>
						<li><a href="?dataID='. $row['IPT_ID'] .'" class="active">全部</a></li>
						';
						do{
							$retStr .= '<li><a href="?dataID='. $rs['IPT_ID'] .'">'. $rs['IPT_theme'] .'</a></li>';
						}while ($rs = $typeexe->fetch());

					$retStr .= '
					</ul>
					</nav>
					</div>
					';
			}
			$typeexe = null; */
		}

		foreach ($typeArr as $key => $val){
			$retStr .= '
				<div class="hostTitle active" id="host'. $key .'"><p><span>'. $val .'</span></p></div><!--  onclick="OpenHiddenBox(this.id)" -->
				<ul class="hostItem" id="host'. $key .'Box">
				';

			$dataexe = $DB->query('select * from '. OT_dbPref .'idcProData where IPD_typeStr like "%,'. $key .',%" order by IPD_time DESC');
			if (! $rs = $dataexe->fetch()){
				$retStr .= '<div style="padding:16px;text-align:center;">暂无产品</div>';
			}else{
				do{
					$listStr = '';
					$fieldArr = explode('<arr>', $row['IPT_fieldStr'] .'<arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr><arr>');
					for ($i=1; $i<=$row['IPT_fieldNum']; $i++){
						$itemArr = explode('|', $fieldArr[$i-1] .'|||||');
						if ($itemArr[0] == 1 && $itemArr[3] == 1){
							$listStr .= '<p style="color:'. $itemArr[2] .'">'. $itemArr[1] .'：'. $rs['IPD_field'. $i] .'</p>';
						}
					}

					if ($row['IPT_priceType'] == 'vps1'){
						$priceStr = '<div class="priceBox price2"><span>'. floatval($rs['IPD_priceMonth']) .'</span>元/月 <span>'. floatval($rs['IPD_priceYear']) .'</span>元/年</div>';
					}else{
						$priceStr = '<div class="priceBox">¥'. floatval($rs['IPD_priceYear']) .'/年</div>';
					}
					if (strlen($rs['IPD_goUrl']) > 7){
						$btnStr = '<div class="btnBox"><input type="button" class="btn" value="立即购买" onclick="document.location.href=\''. $rs['IPD_goUrl'] .'\';" /></div>';
					}else{
						$btnStr = '';
					}

					$retStr .= '
					<li>
						<div class="markBox"><i class="imgHot"></i><!-- 热销 --></div>
						<a class="itemA">
							<div class="itemLeft">
								<div class="title">'. $rs['IPD_theme'] .'</div>
								<div class="note">'. $listStr .'</div>
							</div>
							<div class="itemRight">
								'. $btnStr .'
								'. $priceStr .'
							</div>
						</a>
					</li>
					';
				}while ($rs = $dataexe->fetch());
			}

			$retStr .= '
				</ul>
				';
		}

		return $retStr;
	}

}

?>